package com.cftpay.payexperience.usage.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.cftpay.payexperience.R;
import com.cftpay.payexperience.usage.loader.GlideImageLoader;
import com.cftpay.payexperience.usage.util.PayToastUtil;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;

import static sdk.pay.constant.PayExternalConstant.PAY_STATUS;
import static sdk.pay.constant.PayExternalConstant.REQUEST_CODE;
import static sdk.pay.constant.PayExternalConstant.RESULT_CODE;
import static sdk.pay.constant.PayExternalConstant.ZERO_CODE;
import static sdk.pay.listener.PayGetPayStatusListener.SUCCESS;


/**
 * Created by Administrator on 2016/9/8.
 */
public class ExperienceActivity extends Activity implements View.OnClickListener {
    private Banner banner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_experience);
        initView();
    }

    private void initView() {
        findViewById(R.id.share_experience_btn).setOnClickListener(this);
        findViewById(R.id.rich_scan_experience_btn).setOnClickListener(this);
        findViewById(R.id.wap_experience_btn).setOnClickListener(this);
        banner = (Banner) findViewById(R.id.banner);
        List<Integer> list = new ArrayList<>();
        list.add(R.drawable.icon_banner_one);
        list.add(R.drawable.icon_banner_two);
        list.add(R.drawable.icon_banner_three);
        banner.setImages(list)
                .setImageLoader(new GlideImageLoader())
                .start();
    }

    @Override
    public void onClick(View v) {
        String type = "";
        switch (v.getId()) {
            case R.id.share_experience_btn:
                type = "1";
                break;
            case R.id.rich_scan_experience_btn:
                type = "2";
                break;
            case R.id.wap_experience_btn:
                type = "3";
                break;
        }
        PayActivity.startActivity(this, type);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (REQUEST_CODE == requestCode) {
            if (RESULT_CODE == resultCode) {
                int payStatus = data.getIntExtra(PAY_STATUS, ZERO_CODE);
                if (payStatus == SUCCESS) {
                    PayToastUtil.showMessage(this, getString(R.string.pay_success));
                } else {
                    PayToastUtil.showMessage(this, getString(R.string.pay_failure));
                }
            }

        }
    }

}

